package com.umeox.moto.common.clicklistener;

import android.os.SystemClock;
import android.view.View;

/**
 * Created by Rambo 2023/7/22
 * Describe:
 */

public abstract class OnNoDoubleClickListener implements View.OnClickListener {

    // 0.9秒内防止多次点击
    public static final int MIN_CLICK_DELAY_TIME = 1000;
    private long lastClickTime = 0;

    @Override
    public void onClick(View v) {
        long currentTime = SystemClock.elapsedRealtime();
        if (currentTime - lastClickTime > MIN_CLICK_DELAY_TIME) {
            lastClickTime = currentTime;
            onNoDoubleClick(v);
        }
    }

    // 用户需要进一步实现
    protected abstract void onNoDoubleClick(View v);

}
